home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 83win / data1.cab / Basic_Plus_Examples / COMBWDGT < prev    next >
Text File  |  2001-03-02  |  7KB  |  151 lines

  1. 10    ! ***********************************************
  2. 20    ! Example: COMBO Widget
  3. 30    !
  4. 40    ! This program creates a COMBO widget and allows
  5. 50    ! the user to select an item from a supplied list
  6. 60    ! or to enter text via the keyboard.
  7. 70    !
  8. 80    ! ***********************************************
  9. 90    !
  10. 100       DIM Items$(0:15)[26],Sel$[1000]
  11. 110       INTEGER I,Sel,Fg,Bg,Lb_fg,Lb_bg
  12. 120       Items$(0)="  6 BY 12"
  13. 130       Items$(1)="  8 BY 16"
  14. 140       Items$(2)="  10 BY 20"
  15. 150       Items$(3)="  EDITABLE"
  16. 160       Items$(4)="  NOT EDITABLE"
  17. 170       Items$(5)="  USE DROPDOWN BUTTON"
  18. 180       Items$(6)="  NO DROPDOWN BUTTON"
  19. 190       Items$(7)="  SHOW LIST"
  20. 200       Items$(8)="  HIDE LIST"
  21. 210       Items$(9)="  SHOW SCROLLBAR"
  22. 220       Items$(10)="  HIDE SCROLLBAR"
  23. 230       Items$(11)="  SET COLORS"
  24. 240       FOR I=BASE(Items$,1)+12 TO BASE(Items$,1)+SIZE(Items$,1)-1
  25. 250           Items$(I)="item "&VAL$(I)
  26. 260       NEXT I
  27. 270       ASSIGN @Combo TO WIDGET "COMBO";SET ("ITEMS":Items$(*),"TITLE":" Example: COMBO Widget","COLUMNS":MAXLEN(Items$(0)))
  28. 280       CONTROL @Combo;SET ("X":100,"Y":50,"WIDTH":250,"BACKGROUND":1,"LIST BACKGROUND":1)
  29. 290       CONTROL @Combo;SET ("SYSTEM MENU":"Quit")
  30. 300       ON EVENT @Combo,"SELECTION" GOSUB Disp_sel
  31. 310       ON EVENT @Combo,"KEYSTROKE" GOSUB Disp_keystroke
  32. 320       ON EVENT @Combo,"RETURN" GOSUB Disp_return
  33. 330       ON EVENT @Combo,"SYSTEM MENU" GOTO Finis
  34. 340       LOOP
  35. 350           WAIT FOR EVENT
  36. 360       END LOOP
  37. 370 !
  38. 380  Disp_sel:!
  39. 390       STATUS @Combo;RETURN ("SELECTION":Sel)
  40. 400       STATUS @Combo;RETURN ("TEXT":Sel$)
  41. 410       DISP
  42. 420       DISP "selection: ";Sel;"""";Sel$;""""
  43. 430       SELECT Sel
  44. 440       CASE 0,1,2
  45. 450           CONTROL @Combo;SET ("FONT":Sel$,"COLUMNS":MAXLEN(Items$(0)))
  46. 460       CASE 3,4
  47. 470           CONTROL @Combo;SET ("EDITABLE":Sel=3)
  48. 480       CASE 5,6
  49. 490           CONTROL @Combo;SET ("DROPDOWN BUTTON":Sel=5)
  50. 500       CASE 7,8
  51. 510           CONTROL @Combo;SET ("SHOW LIST":Sel=7)
  52. 520       CASE 9,10
  53. 530           CONTROL @Combo;SET ("SCROLLBAR":Sel=9)
  54. 540       CASE 11
  55. 550           CONTROL @Combo;SET ("SENSITIVE":0)
  56. 560           STATUS @Combo;RETURN ("PEN":Fg,"BACKGROUND":Bg,"LIST PEN":Lb_fg,"LIST BACKGROUND":Lb_bg)
  57. 570           IF FNQuery_colors(Fg,Bg,Lb_fg,Lb_bg) THEN
  58. 580               CONTROL @Combo;SET ("PEN":Fg,"BACKGROUND":Bg,"LIST PEN":Lb_fg,"LIST BACKGROUND":Lb_bg)
  59. 590           END IF
  60. 600           CONTROL @Combo;SET ("SENSITIVE":1)
  61. 610       END SELECT
  62. 620       RETURN
  63. 630 !
  64. 640  Disp_keystroke:!
  65. 650       STATUS @Combo;RETURN ("TEXT":Sel$)
  66. 660       DISP
  67. 670       DISP "keystroke: """;Sel$;""""
  68. 680       RETURN
  69. 690 !
  70. 700  Disp_return:!
  71. 710       STATUS @Combo;RETURN ("TEXT":Sel$)
  72. 720       DISP
  73. 730       DISP "return: """;Sel$;""""
  74. 740       RETURN
  75. 750  Finis:!
  76. 760       ASSIGN @Combo TO *! Delete COMBO widget
  77. 770       END
  78. 780   !
  79. 790       DEF FNQuery_colors(INTEGER Fg,Bg,Lb_fg,Lb_bg)
  80. 800           INTEGER Num_pens(0:0),Max_pen,Xoffset,Nw_height,Yoffset,Demo_offset
  81. 810           GESCAPE CRT,1;Num_pens(*)
  82. 820           Max_pen=Num_pens(0)
  83. 830           Xoffset=10+17*CHRX
  84. 840           Demo_offset=Xoffset+7*CHRX
  85. 850           Yoffset=10
  86. 860     !
  87. 870     ! Edit colors
  88. 880     !
  89. 890           ASSIGN @Panel TO WIDGET "PANEL";SET ("TITLE":"Select COMBO Colors","X":10,"Y":10,"VISIBLE":0),TRANSIENT
  90. 900           ASSIGN @Fg_label TO WIDGET "LABEL";SET ("VALUE":"Edit Pen","JUSTIFICATION":"RIGHT","X":10,"Y":Yoffset,"COLUMNS":15,"BORDER":0),PARENT @Panel
  91. 910           ASSIGN @Fg TO WIDGET "NUMBER";SET ("X":Xoffset,"Y":Yoffset,"COLUMNS":4,"FORMAT":"SHORT INTEGER","MINIMUM":0,"MAXIMUM":Max_pen,"VALUE":Fg),PARENT @Panel
  92. 920           STATUS @Fg;RETURN ("HEIGHT":Nw_height)
  93. 930           ASSIGN @Edit_demo TO WIDGET "LABEL";SET ("VALUE":"Edit Colors","X":Demo_offset,"Y":Yoffset,"COLUMNS":15,"HEIGHT":2*Nw_height,"PEN":Fg,"BACKGROUND":Bg),PARENT @Panel
  94. 940           Yoffset=Yoffset+Nw_height
  95. 950           ASSIGN @Bg_label TO WIDGET "LABEL";SET ("VALUE":"Edit Background","JUSTIFICATION":"RIGHT","X":10,"Y":Yoffset,"COLUMNS":15,"BORDER":0),PARENT @Panel
  96. 960           ASSIGN @Bg TO WIDGET "NUMBER";SET ("X":Xoffset,"Y":Yoffset,"COLUMNS":4,"FORMAT":"SHORT INTEGER","MINIMUM":0,"MAXIMUM":Max_pen,"VALUE":Bg),PARENT @Panel
  97. 970     !
  98. 980     ! List colors
  99. 990     !
  100. 1000           Yoffset=Yoffset+Nw_height
  101. 1010           ASSIGN @Lb_fg_label TO WIDGET "LABEL";SET ("VALUE":"List Pen","JUSTIFICATION":"RIGHT","X":10,"Y":Yoffset,"COLUMNS":15,"BORDER":0),PARENT @Panel
  102. 1020           ASSIGN @Lb_fg TO WIDGET "NUMBER";SET ("X":Xoffset,"Y":Yoffset,"COLUMNS":4,"FORMAT":"SHORT INTEGER","MINIMUM":0,"MAXIMUM":Max_pen,"VALUE":Lb_fg),PARENT @Panel
  103. 1030           ASSIGN @List_demo TO WIDGET "LABEL";SET ("VALUE":"List Colors","X":Demo_offset,"Y":Yoffset,"COLUMNS":15,"HEIGHT":2*Nw_height,"PEN":Fg,"BACKGROUND":Lb_bg),PARENT @Panel
  104. 1040           Yoffset=Yoffset+Nw_height
  105. 1050           ASSIGN @Lb_bg_label TO WIDGET "LABEL";SET ("VALUE":"List Background","JUSTIFICATION":"RIGHT","X":10,"Y":Yoffset,"COLUMNS":15,"BORDER":0),PARENT @Panel
  106. 1060           ASSIGN @Lb_bg TO WIDGET "NUMBER";SET ("X":Xoffset,"Y":Yoffset,"COLUMNS":4,"FORMAT":"SHORT INTEGER","MINIMUM":0,"MAXIMUM":Max_pen,"VALUE":Lb_bg),PARENT @Panel
  107. 1070           Yoffset=Yoffset+Nw_height+10
  108. 1080           STATUS @List_demo;RETURN ("WIDTH":W)
  109. 1090           STATUS @Panel;RETURN ("WIDTH":Pw,"HEIGHT":Ph,"INSIDE WIDTH":Piw,"INSIDE HEIGHT":Pih)
  110. 1100           Pw=Pw-Piw
  111. 1110           Piw=Demo_offset+W+10
  112. 1120           Pw=Pw+Piw
  113. 1130           ASSIGN @Sep TO WIDGET "SEPARATOR";SET ("X":10,"Y":Yoffset,"WIDTH":Piw-20,"HEIGHT":5),PARENT @Panel
  114. 1140           Yoffset=Yoffset+10
  115. 1150           ASSIGN @Done TO WIDGET "PUSHBUTTON";SET ("X":10+5*CHRX,"Y":Yoffset,"COLUMNS":10,"LABEL":"DONE"),PARENT @Panel
  116. 1160           ASSIGN @Cancel TO WIDGET "PUSHBUTTON";SET ("X":Demo_offset,"Y":Yoffset,"COLUMNS":10,"LABEL":"CANCEL"),PARENT @Panel
  117. 1170           STATUS @Cancel;RETURN ("HEIGHT":H)
  118. 1180           Ph=Ph-Pih
  119. 1190           Pih=Yoffset+H+10
  120. 1200           Ph=Ph+Pih
  121. 1210           CONTROL @Panel;SET ("WIDTH":Pw,"HEIGHT":Ph,"VISIBLE":1)
  122. 1220    !
  123. 1230           ON EVENT @Fg,"RETURN",2 GOSUB Set_edit
  124. 1240           ON EVENT @Fg,"DONE",2 GOSUB Set_edit
  125. 1250           ON EVENT @Bg,"RETURN",2 GOSUB Set_edit
  126. 1260           ON EVENT @Bg,"DONE",2 GOSUB Set_edit
  127. 1270           ON EVENT @Lb_fg,"RETURN",2 GOSUB Set_list
  128. 1280           ON EVENT @Lb_fg,"DONE",2 GOSUB Set_list
  129. 1290           ON EVENT @Lb_bg,"DONE",2 GOSUB Set_list
  130. 1300           ON EVENT @Done,"ACTIVATED",2 GOTO Done
  131. 1310           ON EVENT @Cancel,"ACTIVATED",2 GOTO Cancel
  132. 1320    !
  133. 1330           LOOP
  134. 1340               WAIT FOR EVENT
  135. 1350           END LOOP
  136. 1360  Set_edit:!
  137. 1370           STATUS @Fg;RETURN ("VALUE":Fg)
  138. 1380           STATUS @Bg;RETURN ("VALUE":Bg)
  139. 1390           CONTROL @Edit_demo;SET ("PEN":Fg,"BACKGROUND":Bg)
  140. 1400           RETURN
  141. 1410 !
  142. 1420  Set_list:!
  143. 1430           STATUS @Lb_fg;RETURN ("VALUE":Lb_fg)
  144. 1440           STATUS @Lb_bg;RETURN ("VALUE":Lb_bg)
  145. 1450           CONTROL @List_demo;SET ("PEN":Lb_fg,"BACKGROUND":Lb_bg)
  146. 1460           RETURN
  147. 1470 !
  148. 1480  Done: RETURN 1
  149. 1490  Cancel: RETURN 0
  150. 1500       FNEND
  151.